class Solution:
    def maxSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if not len(nums):
            return 0

        maxSum = nums[0]
        s = max(0, nums[0])

        for n in nums[1:]:
            s += n

            maxSum = max(maxSum, s)
            s = max(0, s)
            
        return maxSum

s = Solution()
print('ss', s.maxSubArray([-1]))
print('ss', s.maxSubArray([-2,1]))
print('ss', s.maxSubArray([-2,1,-3,4,-1,2,1,-5,4]))

